import othersApiUtils from "@/utils/othersApiUtils";

/**
 * 
 * @param wordStr 需要检测的字符串
 * @param isStrict 是否开启严格模式，0是不开启，1是开启
 * @param ColaKey 唯一验证码，有时效性
 * @returns 
 */
export let wordDetectionApi = (wordStr: string, isStrict: number = 0, ColaKey: string = "GpeKXP97NXzo4t1705424248424lQobXFFOlm",) => {
    return othersApiUtils({
        url: "/tools/sensiWords",
        method: "post",
        data: {
            ColaKey,
            wordStr,
            isStrict
        }
    });
}

/**
 * 高级版文心一言的API,使用fetch实现流响应数据
 * @param question 提出的问题
 * @param isLongChat 是否支持上下文，0是不支持，1是支持
 * @param chatModel 自定义使用的模型
 * @param isStream 是否使用流响应格式默认false
 */
export let wenXinBotApi = (question: string, chatModel: "botChat" | "bot7bChat" | "turboChat", isStream: boolean = false, isLongChat: number = 1,) => {
    return othersApiUtils({
        url: "/ai/wxChatV2",
        method: "post",
        responseType: isStream ? "stream" : "json",
        data: {
            ques: question,
            appKey: "65a6b59a4ea016820beda04d",
            uid: "HqoSBW1705424248424MFUAsVDqsU",
            isLongChat: isLongChat,
            chatModel: chatModel,
            isStream: isStream
        }
    });
}

export let wenXinBotApi2 = (question: string, chatModel: "botChat" | "bot7bChat" | "turboChat", isLongChat = 1) => {
    const url = "https://luckycola.com.cn/ai/wxChatV2";
    const data = {
        ques: question,
        appKey: "65a6b59a4ea016820beda04d",
        uid: "HqoSBW1705424248424MFUAsVDqsU",
        isLongChat: isLongChat,
        chatModel: chatModel,
        isStream: true,
    };

    return fetch(url, {
        method: "POST",
        body: JSON.stringify(data),
        headers: {
            "Content-Type": "application/json",
        },
    });
};

// 普通版文心一言的API
export let normalWenXinBotApi = (question: string, isLongChat: number = 1,) => {
    return othersApiUtils({
        url: "/ai/openwxyy",
        method: "post",
        data: {
            ques: question,
            appKey: "65a6b59a4ea016820beda04d",
            uid: "HqoSBW1705424248424MFUAsVDqsU",
            isLongChat: isLongChat,
        }
    });
}